@extends('admin.layouts.admin')
@section('header')
{!! editor_css() !!}
<style>
    .editormd-toolbar{
        position: absolute !important;
        width: 100% !important;
        left: 0px !important;
    }
    .task-list-item-checkbox{
        display: block !important;
    }
    .markdown-body li{
        display: list-item  !important;
        text-align: -webkit-match-parent  !important;
    }
    .markdown-body ol li{
        list-style-type: decimal !important;
    }
</style>
@endsection
@section('content')
    <div class="layui-form" lay-filter="LAY-add-forms" id="LAY-add" style="padding: 20px 30px 0 0;">
        <div class="layui-form-item">
            <label class="layui-form-label">栏目</label>
            <div class="layui-input-block">
                <select name="cid" lay-verify="">
                    @foreach($category as $val)
                        <option value="{{$val['id']}}">{{$val['html']}}{{$val['name']}}</option>
                    @endforeach
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">名称</label>
            <div class="layui-input-block">
                <input type="text" name="name" lay-verify="required" placeholder="请输入文章名称" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">标签</label>
            <div class="layui-input-block">
                @foreach($tag as $value)
                    <input type="checkbox" name="tags[]" title="{{$value->name}}" value="{{$value->id}}">
                @endforeach
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">文章配图</label>
            <div class="layui-input-inline">
                <input type="hidden" name="file_path" id="file_path" placeholder="请上传图片" autocomplete="off" class="layui-input">
                <input type="hidden" name="file_id" id="file_id" placeholder="请上传图片" autocomplete="off" class="layui-input">
                <input type="text" name="file_name" id="file_name" placeholder="请上传图片" autocomplete="off" class="layui-input">
            </div>
            <button type="button" class="layui-btn" id="test-upload-normal" style="float: left">上传配图</button>
            <div class="layui-upload-list  " style="width: 100px;float: left;margin: 0 20px">
                <img class="layui-upload-img"  style="width: 40px;height: 40px" id="test-upload-normal-img">
                <p id="upload-Text"></p>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">描述</label>
            <div class="layui-input-block">
                <textarea name="describe" placeholder="描述" class="layui-textarea" lay-verify="required" rows="3" style="min-height:60px"></textarea>
            </div>
        </div>
        <!-- Markdown编辑器元素 -->
        <div class="layui-form-item">
            <label class="layui-form-label">内容</label>
            <div class="layui-input-block">
                <div id="editormd_id">
                    <textarea name="content_md" style="display:none;"></textarea>
                </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-inline">
                <input type="text" name="order" value="0" lay-verify="required" placeholder="排序" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">是否显示</label>
            <div class="layui-input-block">
                <input type="checkbox" name="status" lay-skin="switch" lay-text="是|否" value="1" checked>
            </div>
        </div>

        <div class="layui-form-item layui-hide">
            <input type="button" lay-submit lay-filter="LAY-add-forms" id="LAY-add-forms" value="确认">
        </div>
    </div>

@endsection
@section('scripts')
    <script src="{{ asset('js/jquery.min.js') }}" type="text/javascript" charset="utf-8"></script>
    {!! editor_js() !!}
    <script>
        layui.config({
            base: '../' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'table', 'form', 'upload'], function(){
            var $ = layui.$
                ,form = layui.form
                ,upload = layui.upload ;
            form.render('checkbox');

            //普通图片上传
            var eleId = "#test-upload-normal";
            var postUrl = "/admin/file/upload";
            var layUpload = upload;
            var exts = 'jpg|png|gif|bmp|jpeg'
            Common.uploadFile(eleId, postUrl, layUpload, "#test-upload-normal-img", exts)

        });//use


    </script>
@stop
